﻿using Inovout.Cloud.Messager.Domain;
using Inovout.Data.Repository;
using Inovout.Web.Mvc;
using System.Linq;
using System.Web.Mvc;

namespace Inovout.Cloud.Messager.WebPage.Controllers
{
    [AllowAnonymous]
    public class HomeController : BaseController
    {
        private IRepository<Message> messageRepository;
        public HomeController()
        {
            //构造器参数类型为泛型，不触发OnActivated事件
            this.messageRepository = Inovout.Component.ComponentRegistry.Resolve<IRepository<Message>>();
            // var result = dao.Query().ToList(); ;
            //string from1 = "A" + System.DateTime.Now.Ticks.ToString();
            //var message = new Message() { From1 = from1 };
            //messageRepository.Save(message);
            //var id = message.Id;
            //Message loadMessage = messageRepository.FindById(id);
            //string from2 = from1 + "B";
            //loadMessage.From1 = from2;
            //messageRepository.Save(loadMessage);
            //Message updatedmessage = messageRepository.FindById(id);
            //if (from2.Equals(updatedmessage.From1))
            //{
            //    messageRepository.Delete(updatedmessage);
            //}
        }
        public ActionResult Index()
        {
            var list = messageRepository.Query().ToList();
            var pagedList = messageRepository.Query().ToPagedSet(1, 1);
            return View();
        }

    }
}